<?php
$params = array_merge(
    require __DIR__ . '/../../common/config/params.php',
    require __DIR__ . '/../../common/config/params-local.php',
    require __DIR__ . '/params.php',
    require __DIR__ . '/params-local.php',
    require __DIR__ . '/rules.php'
);
return [
    'id' => 'cms-api',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'timeZone' => 'Asia/Shanghai',
    'modules' => [
        'v1' => [
            'class' => 'cms\modules\v1\module',
        ]
    ],
    'components' => [
        'request' => [
            'csrfParam' => '_csrf-cms',
        ],
        'on beforeSend' => function ($event) {
            $response = $event->sender;
            $response->format = yii\web\Response::FORMAT_JSON;
        },
        'user' => [
            'identityClass' => 'cms\modules\common\models\Admin',
            'enableAutoLogin' => true,
            'enableSession' => false,
        ],
        
        'session' => [
            // this is the name of the session cookie used for login on the frontend
            'name' => 'cms',
        ],
        
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class'          => 'yii\log\FileTarget',
                    'levels'         => ['info'],
                    'logVars'        => ['_POST'],//不记录PHP全局变量$_POST等
                    'logFile'        => '@cms/runtime/logs/info.log',
                ],
            
                [
                    'class'          => 'yii\log\FileTarget',
                    'levels'         => ['error', 'warning'],
                    'logVars'        => ['_POST', '_SERVER'],//不记录PHP全局变量$_POST等
                    'logFile'        => '@cms/runtime/logs/error.log',
//                    'exportInterval' => 1,//在导出消息之前应该累积多少条消息
                ],
            ],
        ],
        
        'as cors' => [
            'class' => \yii\filters\Cors::className(),
            'cors' => [
                'Origin' => ['*'],
                'Access-Control-Allow-Credentials' => true,
            ],
        ],
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'enableStrictParsing' =>true,
            'rules' => $params['rules']

        ],
    ],
    'params' => $params,
];
